上圖將CLient設計模型, 簡易抽象一下並分層
來看看.Net這裡關於API與SDK的介紹
OTel-dotnet/OTelAPI
開頭就有講得很明確
Application developers and library authors use OpenTelemetry API to instrument their application/library. The API only surfaces necessary abstractions to instrument an application/library. It does not address concerns like how telemetry is exported to a specific telemetry backend, how to sample the telemetry, etc. The API consists of Tracing API, Logging API, Metrics API, Context and Propagation API, and a set of semantic conventions.
開發人員應該使用OTel API來檢測自己的應用程序.
OTel API只有暴露必要的抽向來檢測程序. 並不干涉怎麼把檢測拿到的遙測資料給送到特定的遙測後端, 還有對遙測資料進行採樣等問題.
這如同設計模型講的,這些職責在SDK身上.
在OTel API內有個很特別的模組傳播Propagation, 它作為橫切關注點(Cross-cutting concern), 使用Propagation從資料中讀取和寫入context資料和Baggage資料.
在OTel .NET API中,
有Tracing, Logging, Metrics, Context, Baggage API的部份
其中Logging沒特別用OTel logs api, 而是整合了.net原本的Microsoft.Extensions.Logging API
Context module內有Propagation的部份.
跟OTel client架構符合程度非常的高.
here, 就各資料夾名稱就是
OpenTelemetry SDK is a reference implementation of the OpenTelemetry API. It implements the Tracing API, the Metrics API, and the Context API. Once a valid SDK is installed and configured, all the OpenTelemetry API methods, which were no-ops without an SDK, will start emitting telemetry. This SDK also supports ILogger integration.
The SDK deals with concerns such as sampling, processing pipeline, exporting telemetry to a particular backend etc. In most cases, users indirectly install and enable the SDK, when they install a particular exporter.
跟OTel定義一樣, SDK是API這抽象的實做.
實做了Log API, Metric API, Trace API 甚至還有ContextAPI.
一些配置設定, 採樣, 導出都在這.
通常只有在指定特定的exporter時才會安裝跟啟用SDK.
在OTel .NET SDK內也是有Logs, Metrics, Trace, Resources, 甚至有Proceesor, Exporter, Samplter一些實做.
Exporter部份更多在, here.
here,
Go的Log部份目前進度是Frozen, 其他都還是在蓬勃開發中.
OpenTelemetry在Client模組與套件的設計上真的頗複雜, 思考了非常多.
為了讓每個模組能滿足SOLID中的像是OCP、ISP、SRP, 拆了很多東西出來.
對這些有些初步理解方便於我們去閱讀OpenTelemetry的specification.
有了這些設計規範後, 各語言的社群就能去開發OTel的contrib(3rd-party packages, 包含instrumentation, propagators, detectors...)
相較於Go的文件跟資料夾分類, 我覺得.net這邊的可讀性比較豐富就是了,
希望有天能幫忙Go這裡補充資訊.
ps. 8月忙著裝潢&搬家, 9月忙鐵人賽跟找工作, 好多事情嘎在一起QQ
這次準備非常不充足, 請多見諒.